var express = require('express');
var router = express.Router();
var db = require('../config/db');

/* GET home page. */
router.post('/pc_count', function(req, res, next) {
  	try {
			var sql = "select count(*) as c from pc group by pc_libname";
			db.query(sql, function(err, rows) {
				if(err) {
					console.log(err.toString());
				} else {
					if(rows.length !== 0) {		
						console.log(rows);
						res.send({
							jsondata: rows
						});
					} else
						res.send({
							jsondata: {}
						});
				}
			});
		} catch(e) {
			console.log(e.toString());
		}
});
router.post('/pc_os', function(req, res, next) {
  	try {
			var sql = "select pc_os,count(*) as c from pc group by pc_os";
			db.query(sql, function(err, rows) {
				if(err) {
					console.log(err.toString());
				} else {
					if(rows.length !== 0) {		
						console.log(rows);
						res.send({
							jsondata: rows
						});
					} else
						res.send({
							jsondata: {}
						});
				}
			});
		} catch(e) {
			console.log(e.toString());
		}
});



module.exports = router;
